﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TbDataSync
{
    /// <summary>
    /// 时间处理相关
    /// </summary>
    public static class TimeFactory
    {
        /// <summary>
        /// 任意时间转unix毫秒时间戳
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static long GetUnixTimestamp(DateTime dateTime) => new DateTimeOffset(dateTime.AddHours(8)).ToUnixTimeSeconds() * 1000;

        /// <summary>
        /// 当前时间转unix毫秒时间戳
        /// </summary>
        /// <returns></returns>
        public static long GetUnixTimestampNow() => new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds() * 1000;
    }
}
